#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Block Name Change"
#define VERSION "1.0"
#define AUTHOR "Tequila aka Zabijaka"

new const name[] = "name";
new const messageName[] = "#Cstrike_Name_Change"

new gCvarActive;

public plugin_init( ){
	register_plugin(PLUGIN, VERSION, AUTHOR);
	gCvarActive = register_cvar("amx_bnc_active", "1");
	register_message( get_user_msgid( "SayText" ), "MessageSayText" );
}

public client_infochanged(id){
	if(!is_user_connected(id))
		return;
	if(!get_pcvar_num(gCvarActive))
		return;
		
	new szNewName[ 32 ];
	new szOldName[ 32 ];
	get_user_info(id, name, szNewName, 31);
	get_user_name(id, szOldName, 31);
	if(!equal(szNewName, szOldName)){
		set_user_info(id, name, szOldName);
	}
}

public MessageSayText(msgid, msgdest, id) {
	if(!get_pcvar_num(gCvarActive))
		return PLUGIN_CONTINUE;

	new message[sizeof(messageName) + 1];
	get_msg_arg_string( 2, message, charsmax(message));
	
	if( equal( message, messageName ))
		return PLUGIN_HANDLED 
	
	return PLUGIN_CONTINUE;
}
